package csel.view.status;

import java.awt.event.ActionListener;

import javax.swing.JPanel;
import csel.model.items.*;
import csel.model.skills.Skill;
import csel.model.entity.Character;

public class BottomMenu extends JPanel{

	private static final long serialVersionUID = 1L;
	
	private final SkillMenu mySkillMenu;
	private final InventoryMenu myInvMenu;
	private final EquipmentMenu myEquipMenu;
	private final SystemMenu mySystemMenu;
	private final StatsMenu myStatsMenu;
	
	private int currentMode;
	
	public BottomMenu(Character myCharacter, ActionListener myListener)
	{
		mySkillMenu = SkillMenu.initialize(myCharacter,myListener);
		myInvMenu = InventoryMenu.initialize(myCharacter.getUsableItems(), myCharacter.getEquippableItems(), myListener);
		myEquipMenu = EquipmentMenu.initialize(myCharacter,myListener);
		mySystemMenu = SystemMenu.initialize(myListener);
		myStatsMenu = StatsMenu.initialize(myCharacter);
		
		currentMode = 0;
		setMenu(0);
		
		//setBackground(Color.BLACK);
		setOpaque(false);
	}
	
	//this logic is encapsulated within the view so these ints should be okay!
	//stats == 0, skills == 1, inv == 2, equip == 3, system == 4
	public void setMenu(int menuNum)
	{
		removeAll();
		
		if (menuNum == 0)
		{
			add(myStatsMenu);
		}
		else if (menuNum == 1)
		{
			add(mySystemMenu);
		}
		else
		{
			add(mySkillMenu);
		}
		
		revalidate();
		repaint();
	}
	
	public void toggleMenu()
	{
		currentMode = ++currentMode % 2;
		setMenu(currentMode);
	}
	
	public void setCharacter(Character myCharacter)
	{
		myInvMenu.setInventories(myCharacter.getUsableItems(),myCharacter.getEquippableItems());
		mySkillMenu.setCharacter(myCharacter);
		myEquipMenu.setCharacter(myCharacter);
		myStatsMenu.setCharacter(myCharacter);
	}
	
	public TakeableItem getSelectedItem()
	{
		return myInvMenu.getSelectedItem();
	}
	
	public Skill getSelectedSkill()
	{
		return mySkillMenu.getSelectedSkill();
	}
	
	public EquippableItem getSelectedEquipment()
	{
		return myEquipMenu.getSelectedEquipment();
	}
}
